﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Factory
{
    public class Simple
    {
        public interface IProduct { }

        public class ConcreteProductA : IProduct { }
        public class ConcreteProductB : IProduct { }

        public class Factory
        {
            //由工厂决定到底实例化哪个子类。
            public IProduct Create()
            {
                return new ConcreteProductA();
            }
        }
    }


    public enum Category
    {
        A, B
    }

    public static class ProductFactory
    {
        public static Simple.IProduct Create(Category category)
        {
            switch (category)
            {
                case Category.A: return new Simple.ConcreteProductA();
                case Category.B: return new Simple.ConcreteProductB();
                default: throw new NotSupportedException();
            }
        }
    }
}
